package com.jeomo.mem.api.fallback;

import com.jeomo.common.core.result.CommonResult;
import com.jeomo.mem.api.IMemberCardApi;
import com.jeomo.mem.api.dto.MemberCardDto;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MemberCardFeignServiceFallbackFactory implements FallbackFactory<IMemberCardApi> {

    public class MemberCardFeignServiceFallback implements IMemberCardApi {

        @Override
        public CommonResult<MemberCardDto> queryByCode(String code) {
            System.out.println("这是一个正常请求");
            return null;
        }

        @Override
        public CommonResult<MemberCardDto> queryByCodeException(String code) {
            System.out.println("这是一个异常请求");
            return null;
        }

        @Override
        public CommonResult<MemberCardDto> queryByCodeOvertime(String code) {
            System.out.println("这是一个超时请求");
            return null;
        }
    }


    @Override
    public IMemberCardApi create(Throwable cause) {
        cause.printStackTrace();
        return new MemberCardFeignServiceFallback();
    }

}
